package org.jclip.examples.helloworld;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */




import java.util.Date;
import java.util.HashMap;

import javax.swing.JMenu;

import org.jclip.runtime.JavaClientPage;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.GroupLayout;
import javax.swing.JPanel;
import com.toedter.calendar.*;

import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
 *
 * @author kissmyirish
 */
public class DoodleDays extends JavaClientPage {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private HashMap<String, Object> hm = new HashMap<String,Object>();
	private JMenu menu = new JMenu("Days");
	private String pageTitle = "MyDoodle.com Calendar";

    /**
     * Creates new form DoodleDays
     */
    public DoodleDays(HashMap<String,Object> hm) {
    	super(hm);
    	this.hm=hm;
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        upperPanel = new javax.swing.JPanel();
        doodle = new javax.swing.JLabel();
        signIN = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        lowerPanel = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        nextButton = new javax.swing.JButton();
        backButton = new javax.swing.JButton();

        setBackground(new java.awt.Color(0, 102, 204));
        setPreferredSize(new java.awt.Dimension(683, 830));

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        upperPanel.setBackground(new java.awt.Color(255, 255, 255));

        doodle.setFont(new java.awt.Font("Arial Black", 1, 36)); // NOI18N
        doodle.setForeground(new java.awt.Color(51, 102, 255));
        doodle.setText("MyDoodle");

        signIN.setBackground(new java.awt.Color(255, 255, 255));
        signIN.setForeground(new java.awt.Color(0, 102, 204));
        signIN.setText("Sign in");

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 102, 204));
        jLabel1.setText("Schedule an event");

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel2.setForeground(new java.awt.Color(0, 102, 204));
        jLabel2.setText("1. General >");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel3.setText("2. Time proposals >");

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(102, 102, 102));
        jLabel4.setText("3. Settings >");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel5.setForeground(new java.awt.Color(102, 102, 102));
        jLabel5.setText("4. Invite");

        javax.swing.GroupLayout upperPanelLayout = new javax.swing.GroupLayout(upperPanel);
        upperPanelLayout.setHorizontalGroup(
        	upperPanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(upperPanelLayout.createSequentialGroup()
        			.addGap(20)
        			.addGroup(upperPanelLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(upperPanelLayout.createSequentialGroup()
        					.addComponent(jLabel1)
        					.addContainerGap())
        				.addGroup(Alignment.TRAILING, upperPanelLayout.createSequentialGroup()
        					.addComponent(doodle)
        					.addPreferredGap(ComponentPlacement.RELATED, 387, Short.MAX_VALUE)
        					.addComponent(signIN)
        					.addGap(55))
        				.addGroup(upperPanelLayout.createSequentialGroup()
        					.addComponent(jLabel2)
        					.addGap(18)
        					.addComponent(jLabel3)
        					.addGap(18)
        					.addComponent(jLabel4)
        					.addGap(18)
        					.addComponent(jLabel5)
        					.addGap(0, 287, Short.MAX_VALUE))))
        );
        upperPanelLayout.setVerticalGroup(
        	upperPanelLayout.createParallelGroup(Alignment.TRAILING)
        		.addGroup(upperPanelLayout.createSequentialGroup()
        			.addContainerGap(31, Short.MAX_VALUE)
        			.addGroup(upperPanelLayout.createParallelGroup(Alignment.LEADING)
        				.addComponent(signIN)
        				.addComponent(doodle, GroupLayout.PREFERRED_SIZE, 40, GroupLayout.PREFERRED_SIZE))
        			.addGap(18)
        			.addComponent(jLabel1)
        			.addGap(18)
        			.addGroup(upperPanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(jLabel2)
        				.addComponent(jLabel3)
        				.addComponent(jLabel4)
        				.addComponent(jLabel5))
        			.addContainerGap())
        );
        upperPanel.setLayout(upperPanelLayout);

        lowerPanel.setBackground(new java.awt.Color(215, 234, 253));
        lowerPanel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 255, 255), 5));

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
        jLabel6.setText("Days");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel7.setText("Click on the dates you would like to choose.");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabel8.setForeground(new java.awt.Color(0, 102, 204));
        jLabel8.setText("Calendar view | Free text");

 //       jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("calendarView.png"))); // NOI18N
 //       jLabel9.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        jPanel5.setBackground(new java.awt.Color(215, 234, 253));

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel10.setText("Selected dates:");
        
        JLabel jLabel11 = new JLabel("");
        
        jPanel5.setLayout(new GridLayout(10,1));
        jPanel5.add(jLabel10);
        jPanel5.add(jLabel11);
        
        JButton[] btns = cld.getDays();
        for(JButton button: btns){
        	button.addActionListener(new ActionListener(){
        		public void actionPerformed(ActionEvent e){
        			JButton button = (JButton) e.getSource();
        			String buttonText = button.getText();
        			int day = new Integer(buttonText).intValue();
        			int month = cld.getMonthChooser().getMonth();
        			int year = cld.getYearChooser().getYear();
        			JLabel date = new JLabel(""+day+"/"+month+"/"+year);
        			date.setFont(new java.awt.Font("Tahoma", 0, 14));
        			jPanel5.add(date);
        			cld.getDayChooser().setDay(day);
        			hm.put("Date "+counter++, date);
        			jPanel5.validate();
        		}
        	});
        }
        
        cld.setSize(300,300);
        
        nextButton.setText("Next");
        nextButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	hm.put("Date counter", ""+counter);
                browser.go("http://localhost//org.jclip.examples.helloworld//bin//#org.jclip.examples.helloworld.DoodleTime", hm);
            }
        });

        backButton.setText("Back");
        backButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	browser.go("http://localhost//org.jclip.examples.helloworld//bin//#org.jclip.examples.helloworld.DoodleScheduleEvent", hm);
            }
        });
        

        javax.swing.GroupLayout lowerPanelLayout = new javax.swing.GroupLayout(lowerPanel);
        lowerPanelLayout.setHorizontalGroup(
        	lowerPanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(lowerPanelLayout.createSequentialGroup()
        			.addContainerGap()
        			.addGroup(lowerPanelLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(lowerPanelLayout.createSequentialGroup()
        					.addComponent(cld, GroupLayout.PREFERRED_SIZE, 254, GroupLayout.PREFERRED_SIZE)
        					.addGap(51)
        					.addComponent(jPanel5, GroupLayout.PREFERRED_SIZE, 322, GroupLayout.PREFERRED_SIZE)
        					.addContainerGap())
        				.addGroup(lowerPanelLayout.createSequentialGroup()
        					.addComponent(jLabel6)
        					.addPreferredGap(ComponentPlacement.RELATED, 451, Short.MAX_VALUE)
        					.addComponent(jLabel8)
        					.addGap(26))
        				.addGroup(lowerPanelLayout.createSequentialGroup()
        					.addComponent(backButton, GroupLayout.PREFERRED_SIZE, 66, GroupLayout.PREFERRED_SIZE)
        					.addPreferredGap(ComponentPlacement.RELATED)
        					.addComponent(nextButton, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE))
        				.addGroup(lowerPanelLayout.createSequentialGroup()
        					.addComponent(jLabel7)
        					.addContainerGap(414, Short.MAX_VALUE))))
        );
        lowerPanelLayout.setVerticalGroup(
        	lowerPanelLayout.createParallelGroup(Alignment.LEADING)
        		.addGroup(lowerPanelLayout.createSequentialGroup()
        			.addGap(28)
        			.addGroup(lowerPanelLayout.createParallelGroup(Alignment.BASELINE)
        				.addComponent(jLabel6)
        				.addComponent(jLabel8))
        			.addGap(33)
        			.addComponent(jLabel7)
        			.addPreferredGap(ComponentPlacement.RELATED)
        			.addGroup(lowerPanelLayout.createParallelGroup(Alignment.LEADING)
        				.addGroup(lowerPanelLayout.createSequentialGroup()
        					.addComponent(cld, GroupLayout.PREFERRED_SIZE, 200, GroupLayout.PREFERRED_SIZE)
        					.addGap(84)
        					.addGroup(lowerPanelLayout.createParallelGroup(Alignment.BASELINE)
        						.addComponent(backButton)
        						.addComponent(nextButton)))
        				.addComponent(jPanel5, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
        			.addGap(116))
        );
        lowerPanel.setLayout(lowerPanelLayout);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(upperPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(lowerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(upperPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(lowerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(jPanel1);
        jScrollPane1.getVerticalScrollBar().setUnitIncrement(16);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 750, Short.MAX_VALUE)
        );

    }// </editor-fold>//GEN-END:initComponents


    
    public JMenu getMenus()
    {
    	return menu;
    }

    public String getTitle()
    {
    	return pageTitle;
    }
    
  

    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton backButton;
    private javax.swing.JLabel doodle;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JPanel lowerPanel;
    private javax.swing.JButton nextButton;
    private javax.swing.JLabel signIN;
    private javax.swing.JPanel upperPanel;
    private javax.swing.JPanel jPanel5 = new JPanel();
    private JCalendar cld = new JCalendar();
    private int counter = 1;

}
